import { App, Group, Leafer } from 'leafer-ui'
import useHistoryUtil from '../hooks/useHistoryUtil'
import { ComputedRef, Ref } from 'vue'

export interface IToolConfig {
	pen: {
		color: string
		strokeWidth: number
		opcity: number
	}
	eraser: {
		size: number
	}
	text: {
		fontSize: number
		color: string
    limitBox?: boolean
	}
	shape: {
		color: string
		strokeWidth: number
		type: 'rect' | 'circle' | 'square' | 'triangle'
	}
}
export type IToolType = keyof IToolConfig
export type IToolReturn = {
	eventsMap: Record<string, (event: any) => void>
	active: () => void
	deactive: () => void
}
export interface IUseHistoryUtil<T> {
	data: Ref<T | undefined>
	init: (initialData: T) => void
	commit: (data: T) => void
	redo: () => void
	undo: () => void
	canRedo: ComputedRef<boolean>
	canUndo: ComputedRef<boolean>
	index: Ref<number>
	getCloneData: () => T
	getHistoryList: () => T[]
}
export type ITool = (options: {
	app: App
	config: IToolConfig
	commit:()=>void;
	target: () => Group | Leafer
}) => IToolReturn
